{% extends "account/base.html" %}

{% load i18n %}
{% load widget_tweaks %}

{% block head_title %}{% trans "Change Password" %}{% endblock %}

{% block content %}
<div class="container">
  <div class="row justify-content-center logreg">
          <div class="col-sm-11 col-md-8 col-lg-6">
              <div id="logreg-forms">

            <h1 class="text-center">{% if token_fail %}{% trans "Bad Token" %}{% else %}{% trans "Change Password" %}{% endif %}</h1>
            <div style="width: 100%; height: 20px; border-bottom: 1px solid var(--color-divider); margin-bottom: 16px;"></div>

      {% if token_fail %}
      {% url 'account_reset_password' as passwd_reset_url %}
      <p>{% blocktrans %}The password reset link was invalid, possibly because it has already been used.  Please request a <a href="{{ passwd_reset_url }}">new password reset</a>.{% endblocktrans %}</p>
  {% else %}
      {% if form %}

      <form class="signup form-signup" method="POST" action="{{ action_url }}">
              {% csrf_token %}
              {% with WIDGET_ERROR_CLASS='field_error' WIDGET_REQUIRED_CLASS='field_required' %}
              <div class="form-group">
                {% render_field form.password1 class="form-control" aria-describedby="password1Help" placeholder="Password" %}
                {% if form.password1.errors %}
                <small id="password1Help" class="text-danger">
                  {% for error in form.password1.errors %}
                  {{ error|escape }}
                  {% endfor %}
                </small>
                {% else %}
                <small id="password1Help" class="form-text">At least 6 characters. And be secure, please.</small>
                {% endif %}
              </div>
              <div class="form-group">
                {% render_field form.password2 class="form-control" aria-describedby="password2Help" placeholder="Password. Again" %}
                {% if form.password2.errors %}
                <small id="password2Help" class="text-danger">
                    {% for error in form.password2.errors %}
                    {{ error|escape }}
                    {% endfor %}
                  </small>
                  {% endif %}
              </div>
              {% endwith %}
              <button type="submit" class="btn btn-primary btn-block">{% trans 'Change Password' %}</button>
            </form>

            {% else %}
            <p>{% trans 'Your password is now changed.' %}</p>
        {% endif %}
    {% endif %}

  </div>
  </div>
  </div>
</div>
{% endblock %}
